/*
 * Copyright 2016-2016 the original author or authors.
 * Created on 2016/12/27 下午1:47
 */
package cn.com.geasy.base;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.domain.Persistable;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.util.Date;

/**
 * 实体父类。通用的字段请在该类中定义，所有的实体类必需继承该类。
 *
 * @author Mechanic
 * @version 1.0
 */
@MappedSuperclass
@Getter
@Setter
@ToString
@EqualsAndHashCode
public abstract class BaseEntity implements Persistable<String>{

    private static final long serialVersionUID = -5369264548309734055L;

    /**
     * 主键 ID
     */
    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "id_")
    private String id_;
    /**
     * 备注
     */
    @Column(name = "remark_")
    private String remark_;
    /**
     * 是否有效记录。false 无效，true 有效
     */
    @Column(name = "is_enable_")
    private Boolean isEnable_;
    /**
     * 创建用户
     */
    @Column(name = "created_by_")
    private String createdBy_;
    /**
     * 创建时间
     */
    @Column(name = "created_time_")
    private Date createdTime_;
    /**
     * 最后一次修改的用户
     */
    @Column(name = "last_updated_by_")
    private String lastUpdatedBy_;
    /**
     * 最后一次修改的时间
     */
    @Column(name = "last_updated_time_")
    private Date lastUpdatedTime_;

    @Override
    public String getId() {
        return this.id_;
    }

    @Override
    public boolean isNew() {
        return this.id_ == null;
    }
}
